package ControlComponents;

import DataFormatConversionComponents.NumberConverter;
import Exceptions.InvalidArrayLengthException;

/**
 * 
 *  This class represents an 8 bit program counter
 *
 */
public class ProgramCounter {
	
	private int[] pc;
	
	public ProgramCounter(){
		pc = new int[8];
	}
		
	public int getIntValue(){
		return new NumberConverter().binaryToDecimal(pc);	
	}
		
	public void set(int[] data) throws InvalidArrayLengthException{
		if( data.length != 8 )
			throw new InvalidArrayLengthException("Cannot set program counter. Expected data.length = 8. Received +" +
					"data.length = " + data.length );
		//copy data to instruction register
		for( int i = 0; i < data.length; i++ )
			pc[i] = data[i];
	}
	
	public int[] get(){
		return pc;
	}
}
